﻿using UnityEngine;
using System.Collections;

public class SquareAnimation : MonoBehaviour {

	Square sqr;
	SquareMove sqrMov;

	// Use this for initialization
	void Start () {
		sqr = GetComponent<Square> ();
		sqrMov = GetComponent<SquareMove> ();

		sqrMov.evtSqMov += SquareMoveAnimation;
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void SquareMoveAnimation(object sender, MsgSquareMove move)
	{
		if (move.eAction == ESquareMoveState.eStartTranslate)
		{
			sqr.leader.DoMove(true);
		}

		if (move.eAction == ESquareMoveState.eStopTranslate)
		{
			sqr.leader.DoMove(false);
		}

		if (move.eAction == ESquareMoveState.eStartRotation)
		{
			sqr.leader.DoTurn(true);
		}

		if (move.eAction == ESquareMoveState.eStopRotation) 
		{
			sqr.leader.DoTurn(false);
		}
	}
}
